package cn.wetcland.urban.admin.controller;

import cn.wetcland.urban.admin.dto.SwiperAddDTO;
import cn.wetcland.urban.admin.dto.SwiperUpdateDTO;
import cn.wetcland.urban.admin.service.UtSwiperService;
import cn.wetcland.urban.common.AjaxResponse;
import cn.wetcland.urban.generator.domain.UtSwiper;
import cn.wetcland.urban.generator.dto.BaseConditionSearchDTO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/swiper")
public class SwiperController {

    @Resource
    private UtSwiperService swiperService;

    @GetMapping("/swiperList")
    public AjaxResponse swiperList(BaseConditionSearchDTO searchDTO) {
        Page<UtSwiper> swiperPage = swiperService.swiperList(searchDTO);
        return AjaxResponse.success(swiperPage);
    }

    @PostMapping("/swiperAdd")
    public AjaxResponse swiperAdd(@RequestBody SwiperAddDTO addDTO) {
        swiperService.swiperAdd(addDTO);
        return AjaxResponse.success();
    }

    @PutMapping("/swiperUpdate")
    public AjaxResponse swiperUpdate(@RequestBody SwiperUpdateDTO updateDTO) {
        swiperService.swiperUpdate(updateDTO);
        return AjaxResponse.success();
    }

    @DeleteMapping("/swiperDelete/{swiperId}")
    public AjaxResponse swiperDelete(@PathVariable Long swiperId) {
        swiperService.swiperDelete(swiperId);
        return AjaxResponse.success();
    }

}
